package com.utils.socket.tcp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * Created by apple on 2017/4/23.
 */
public class TCPClient {
    public static final String IP = "localhost";
    public static final int port = 8962;
    private Socket s;

    public TCPClient() throws IOException {
        try {
            s = new Socket(IP, port);

        } catch (IOException e) {

            e.printStackTrace();
        }
    }

    public void setConnection() throws IOException {

        InputStream is;

        try {
            is = s.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));

            System.out.println(br.readLine());

        } catch (IOException e) {

            e.printStackTrace();
        }

    }

    public static void main(String args[]) throws IOException {

        TCPClient mc = new TCPClient();
        mc.setConnection();

    }

}
